package com.chuanyin.mp3player.process;

import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;

import com.chuanyin.mp3player.BaseActivity;
import com.chuanyin.mp3player.MainActivity;
import com.chuanyin.mp3player.OnlineMusicActivity;
import com.chuanyin.mp3player.R;

public class ButtonProcess implements OnClickListener{
	private ImageButton myMusicBtn;
	private ImageButton onlineBtn ;
	private BaseActivity bActivity;
	private ImageButton functionBtn;
	public ButtonProcess(BaseActivity bActivity){
		this.bActivity = bActivity;
		myMusicBtn = (ImageButton)bActivity.findViewById(R.id.myMusicBtn);
		onlineBtn = (ImageButton)bActivity.findViewById(R.id.onlineBtn);
		functionBtn = (ImageButton)bActivity.findViewById(R.id.functionBtn);
		if(bActivity instanceof MainActivity){
			 functionBtn.setImageResource(R.drawable.system_icon);
		}
		functionBtn.setOnClickListener(this);
	   
		myMusicBtn.setOnClickListener(this);
		onlineBtn.setOnClickListener(this);
	}
	@Override
	public void onClick(View v) {
		switch (v.getId()){
			case R.id.myMusicBtn :
				 myMusicBtn.setImageDrawable(bActivity.getResources().getDrawable(R.drawable.title01));
				 onlineBtn.setImageDrawable(bActivity.getResources().getDrawable(R.drawable.title02));
				 getPlayerMain();
				 break;
			case R.id.onlineBtn :
				 myMusicBtn.setImageDrawable(bActivity.getResources().getDrawable(R.drawable.title03));
				 onlineBtn.setImageDrawable(bActivity.getResources().getDrawable(R.drawable.title04));
				 Intent online = new Intent(bActivity,OnlineMusicActivity.class);
				 bActivity.startActivity(online);
			case R.id.functionBtn:
				 bActivity.onBackPressed();
				 bActivity.finish();
				 break;
			default:
				break;
		}
		
	}
	
	public void getPlayerMain(){
		Intent main = new Intent(bActivity,MainActivity.class);
		bActivity.startActivity(main);
	}
	
	
	
	public BaseActivity getbActivity() {
		return bActivity;
	}
	public void setbActivity(BaseActivity bActivity) {
		this.bActivity = bActivity;
	}
	
	
}
